package models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import play.data.validation.Constraints.Required;
import play.db.ebean.Model;

/**
 * Meta information for test case, test suite and test projects
 * 
 * @author june
 * 
 */
@Entity
@Table(name = "resources")
public class Resource extends Model {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_TABLE")
	@TableGenerator(name = "SEQ_TABLE")
	private long id;
	private ResourceType type;
	@Required
	private String name;
	private String description;
	private String resourcePath;
	private Date createDate;
	private Date lastModified;
	private boolean remote;
	
	public static Finder<Long, Resource> find = new Finder<Long, Resource>(long.class, Resource.class);
	
	/**
	 * Creates a new resource instance.
	 */
	public Resource() {
	}
	
	/**
	 * Creates a new resource instance.
	 * 
	 * @param name The resource name
	 */
	public Resource(String name) {
		this.name = name;
	}
	
	public long getId() {
		return id;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public ResourceType getType() {
		return type;
	}
	
	public void setType(ResourceType type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Get brief description explaining what the object is for which scenario
	 * 
	 * @return
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * Set brief description explaining what the object is for which scenario
	 * 
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * Get path to resource storing object
	 * 
	 * @return
	 */
	public String getResourcePath() {
		return resourcePath;
	}
	
	/**
	 * Set path to resource storing object
	 * 
	 * @param resourcePath
	 */
	public void setResourcePath(String resourcePath) {
		this.resourcePath = resourcePath;
	}
	
	/**
	 * Get create date of the object
	 * 
	 * @return
	 */
	public Date getCreateDate() {
		return createDate;
	}
	
	/**
	 * Set create date of the object
	 * 
	 * @param createDate
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	/**
	 * Get last modified date of the object
	 * 
	 * @return
	 */
	public Date getLastModified() {
		return lastModified;
	}
	
	/**
	 * Set last modified date of the object
	 * 
	 * @param lastModified
	 */
	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}
	
	/**
	 * A flag if this resource is remote resource from robot framework
	 * 
	 * @return
	 */
	public boolean isRemote() {
		return remote;
	}
	
	/**
	 * A flag if this resource is remote resource from robot framework
	 * 
	 * @param remote
	 */
	public void setRemote(boolean remote) {
		this.remote = remote;
	}
	
	@Override
	public String toString() {
		return "Resource [id=" + id + ", type=" + type + ", name=" + name + ", description=" + description + ", resourcePath=" + resourcePath + ", createDate=" + createDate + ", lastModified=" + lastModified + ", remote=" + remote + "]";
	}
	
}
